/*
 *pdflib测试代码:
 *原作者的demo程序
 *Created on: 2019-7-9
 *Author: jun
 */
#include "spdf_ext.h"
#include "dataproc.h"
#include "math.h"
#include "str_ext.h"
#include "framework.h"

SPDF_Doc pdf;
SPDF_Page page;
static short cnt;

SPDF_Doc_Rec pdf_doc;
SPDF_outline_obj_type *otl_list;

void spdf_char_form_tab_create(void);
void spdf_text_demo(void);
void spdf_chart_demo(ii16 dir, ii16 xzoom, ii16 yzoom);
void spdf_color_ref(void);

int spdf_disk_out(uint8_t *buf, int len);
void spdf_outline_demo(void);

/*****************************************************************************
 * @brief   author_demo_api
 * @param   none
 * @return  none
 * @ Pass/ Fail criteria: none
 *****************************************************************************/
void pdf_author_demo(void)
{
	SPDF_Obj *pobj;
	uint8_t *file_buff;

	dbg_puts("pdf out start \n");
	
	pobj = malloc(sizeof(SPDF_Obj) * 120);
	file_buff = malloc(1024 * 4);
	otl_list = malloc(sizeof(SPDF_outline_obj_type) * 32);

	spdf_init(&pdf_doc, pobj, 120);
	spdf_disk_buff_set(&pdf_doc, file_buff, 1024 * 4);
	spdf_disk_out_link(&pdf_doc, spdf_disk_out);
	spdf_font_cns_open(&pdf_doc, 8);
	pdf = spdf_create(&pdf_doc);
	spdf_outline_init(&pdf_doc, otl_list, 32);

	cnt = 1;
	while (cnt--)
	{
		spdf_text_demo();
	}

	spdf_char_form_tab_create();

	spdf_chart_demo(0, 100, 100);
	spdf_chart_demo(1, 100, 100);
	spdf_chart_demo(2, 100, 100);
	spdf_chart_demo(3, 100, 100);

	spdf_save(pdf, "red.pdf");

	free(file_buff);
	free(pobj);
	
	dbg_puts("pdf out end \n");
}
